/**
 * 27/ott/2011
 */
package edu.android;

import java.util.List;

import android.app.ListActivity;
import android.os.Bundle;

/**
 * @author fabiomelillo@gmail.com
 * 
 */
public class MoviesList extends ListActivity {

	private MoviesDB mdb;
	MovieArrayAdapter movieAdapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		movieAdapter=new MovieArrayAdapter(this, R.layout.movielist, this.getMovies());
		setListAdapter(movieAdapter);
	}

//	@Override
//	public void onUserInteraction() {
//		super.onUserInteraction();
////		Toast.makeText(getApplicationContext(), "Interazione:", Toast.LENGTH_LONG).show();
//		movieAdapter = new MovieArrayAdapter(this, R.layout.movielist, getMovies());
//		setListAdapter(movieAdapter);
////		movieAdapter.notifyDataSetChanged();
//	}
	
//	@Override
//	public boolean onTouchEvent(MotionEvent event) {
//		super.onTouchEvent(event);
//		movieAdapter=new MovieArrayAdapter(this, R.layout.movielist, getMovies());
//		setListAdapter(movieAdapter);
//		return true;
//	}

	private List getMovies() {
		mdb = new MoviesDB(getApplicationContext());
		mdb.open();

		return mdb.getMovies();
	}
	
	@Override
	protected void onResume() {
		movieAdapter = new MovieArrayAdapter(this, R.layout.movielist, getMovies());
		setListAdapter(movieAdapter);
		super.onResume();
	}

}
